﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using HUBS1;
using Netprotek_CCvalidator_NET;

namespace JinJiang.BookingEngine.Web.en.usercontrol
{
    public partial class InputCreditCard : UserControl
    {
        private Email _Email = new Email();

        public string ccType
        {
            get
            {
                return CCType.Text;
            }
            set
            {
                CCType.Text = value;
            }
        }

        public string ccName
        {
            get
            {
                return CCName.Text;
            }
            set
            {
                CCName.Text = value;
            }
        }

        public string ccNumber
        {
            get
            {
                return CCEncrypt.Encrypto(CCNumber.Text);
            }
            set
            {
                CCNumber.Text = value;
            }
        }

        public string ccMonth
        {
            get
            {
                return CCExpMonth.Text;
            }
            set
            {
                CCExpMonth.Text = value;
            }
        }

        public string ccYear
        {
            get
            {
                return CCExpYear.Text;
            }
            set
            {
                CCExpYear.Text = value;
            }
        }

        public void CheckCCNumber(object source, ServerValidateEventArgs value)
        {
            var cardno = value.Value;
            try
            {
                CCValidator.Number = cardno;
                value.IsValid = CCValidator.IsValid;
                //_Email.SendMail(cardno + " " + CCValidator.IsValid.ToString(), "信用卡验证");
            }
            catch (SystemException e)
            {
                value.IsValid = false;
            }
        }
    }
}